﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Mimoza.RdpPlugin
{
    public enum Resolution
    {
        Res640x480 = 0,
        Res800x600,
        Res1024x768,
        Res1280x800,
        Res1280x720,
        Res1280x768,
        ResFullScreen
    };

    public enum ColorDepth
    {
        Color8Bit = 0,
        Color16Bit,
        Color24Bit,
        Color32Bit
    };

    public enum Keyboard
    {
        OnThisComupter = 0,
        OnRemoteComputer = 1,
        WhenFullScreen = 2
    };

    public enum Sound
    {
        BringToComputer = 0,
        DoNotPlay,
        LeaveAtRemoteComputer
    };

    public class Devices
    {
        public bool UseDiskDrives;
        public bool UsePrinters = true;
        public bool UseSerialPorts;
        public bool UseSmartCards;
    };

    public class StartProgram
    {
        public bool IsStartEnabled = false;
        public string ProgramPath = "";
        public string ProgramFolder = "";
    }

    public class RdpData
    {
        public string SessionName
        {
            get { return m_sessionName; }
            set { m_sessionName = value; }
        }

        public bool IsStartOnStartup
        {
            get { return m_bIsStartOnStartup; }
            set { m_bIsStartOnStartup = value; }
        }

        public string Computer
        {
            get { return m_computer; }
            set { m_computer = value; }
        }

        public string UserName
        {
            get { return m_userName; }
            set { m_userName = value; }
        }

        public Resolution Resolution
        {
            get { return m_resolution; }
            set { m_resolution = value; }
        }

        public ColorDepth ColorDepth
        {
            get { return m_colorDepth; }
            set { m_colorDepth = value; }
        }

        public bool IsDisplayConnectionBar
        {
            get { return m_bDisplayConnectionBar; }
            set { m_bDisplayConnectionBar = value; }
        }

        public Keyboard Keyboard
        {
            get { return m_keyboard; }
            set { m_keyboard = value; }
        }

        public Sound Sound
        {
            get { return m_sound; }
            set { m_sound = value; }
        }

        public Devices UsingDevice
        {
            get { return m_devices; }
            set { m_devices = value; }
        }

        public StartProgram StartProgram
        {
            get { return m_startProgram; }
            set { m_startProgram = value; }
        }

        public bool IsPersistentShortcut
        {
            get { return m_persistentShortcut; }
            set { m_persistentShortcut = value; }
        }

        public string Serialize()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(RdpData));
            TextWriter text = new StringWriter();
            serializer.Serialize(text, this);
            return text.ToString();
        }

        public static RdpData Deserialize(string data)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(RdpData));
            using (TextReader text = new StringReader(data))
            {
                return deserializer.Deserialize(text) as RdpData;
            }
        }
        
        string m_computer = "";
        string m_userName = "";
        string m_sessionName = "";
        bool m_bIsStartOnStartup = false;

        Resolution m_resolution = Resolution.Res800x600;
        ColorDepth m_colorDepth = ColorDepth.Color16Bit;
        bool m_bDisplayConnectionBar = true;

        Sound m_sound = Sound.BringToComputer;
        Keyboard m_keyboard = Keyboard.WhenFullScreen;
        Devices m_devices = new Devices();

        StartProgram m_startProgram = new StartProgram();

        bool m_persistentShortcut = true;
    }
}
